const joi = require('joi')

/**
 * string() 值必须是字符串
 * alphanum() 值只能是包含 a-zA-Z0-9 的字符串
 * min(length) 最小长度
 * max(length) 最大长度
 * required() 值是必填项，不能为 undefined
 * pattern(正则表达式) 值必须符合正则表达式的规则
 */

// 用户名的验证规则
const name = joi.string().min(1).required()
const p_phone = joi.string().min(1).max(11).required()
const c_id = joi.number().min(1).required()
const id = joi.number().min(1).required()
const is_delete = joi.number().max(1).required()
exports.list_schema = {
  params: {
    class_id: joi.required()
  }
}
exports.getById_schema = {
  params: {
    student_id: joi.required()
  }
}
exports.add_schema = {
  body: {
    name, p_phone, c_id
  }
}
exports.put_schema = {
  body: {
    name, p_phone, c_id, id, is_delete
  }
}

exports.del_schema = {
  params: {
    id
  }
}